#include <fmt/core.h>
#include <fmt/os.h>
#include <cstdio> 

int main () {
    int i = 18; 
    fmt::print("{:+}\n", i);    // sign always
    fmt::print("{:b}\n", i);    // binary
    fmt::print("{:x}\n", i);    // hex
    fmt::print("{:#x}\n", i);   // hex+prefix

    fmt::print("{:6}\n", i);    // width 6
    fmt::print("{:06}\n", i);   // 0-prefixed
    fmt::print("{:>6}\n", i);   // align right
    fmt::print("{:*>6}\n", i);  // align right
    fmt::print("{:*^6}\n", i);  // center
    fmt::print("{:*<6}\n", i);  // align left

    double d = 34.567;
    fmt::print("{:.4}\n", d);   // precision 3
    fmt::print("{:+8.3}\n", d); // width 8
    fmt::print("{:e}\n", d);    // exponential
    fmt::print("{:.3e}\n", d);  // exp+prec
    fmt::print("{:-<12}\n", ""); // line
    fmt::print("{:*>+12.1e}\n", d);

   
    fmt::print("print to stdout\n");
    fmt::print(stdout, "same\n");
    fmt::print(stderr, "warning!\n");

    fmt::ostream out = fmt::output_file("out.txt");
    for (int ln = 0; ln < 4; ++ln) {
        out.print("line {}\n", ln);
    }

    std::FILE* file = std::fopen("out.txt","w");
    for (int ln = 0; ln < 5; ++ln) {
    fmt::print(file, "line {}\n", ln);
    }
    std::fclose(file);

    return 0;
}
